import { Base } from '../../utils/base.js'
class Shop extends Base {
  constructor() {
    super();
  }
  //获取所有基地行业数据
  category(param, cb) {
    var that = this;
    var allParams = {
      url: 'shop/shop-category',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //基地申请状态
  applyStatus(param, cb) {
    var that = this;
    var allParams = {
      url: 'shop/apply-status',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //基地公开信息
  home(param, cb) {
    var that = this;
    var allParams = {
      url: 'shop/home',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //基地信息
  info(param, cb) {
    var that = this;
    var allParams = {
      url: 'seller/info',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //基地资金概况
  record(param, cb) {
    var that = this;
    var allParams = {
      url: 'seller/record',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //商家提现
  withdrawal(param, cb) {
    var that = this;
    var allParams = {
      url: 'seller/withdrawal',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //提交基地申请
  apply(param, cb) {
    var that = this;
    var allParams = {
      url: 'shop/apply',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //二维码验票,获取订单信息
  scan(param, cb,scomplete) {
    var that = this;
    var allParams = {
      url: 'seller/check?expand=orderSku',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
      scomplete: scomplete,
    };
    this.request(allParams);
  }
  //验证票据有效性
  checkout(param, cb, scomplete) {
    var that = this;
    var allParams = {
      url: 'seller/check-out',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
      scomplete: scomplete,
    };
    this.request(allParams);
  }
  //小程序微信支付
  execPay(params, callback,scomplete) {
    var allParams = {
      url: 'seller/recharge',
      type: 'post',
      data: params,
      sCallback: function (data) {
        if (data.is_cash == 1) {
          var data = data.items;
          var timeStamp = data.timeStamp;
          if (timeStamp) { //可以支付
            wx.requestPayment({
              'timeStamp': timeStamp.toString(),
              'nonceStr': data.nonceStr,
              'package': data.package,
              'signType': data.signType,
              'paySign': data.paySign,
              success: function () {
                callback && callback(1);
              },
              fail: function () {
                callback && callback(0);
              }
            });
          } else {
            callback && callback(0);
          }
        } else {
          callback && callback(data);
        }

      },
      scomplete: scomplete,
    };
    this.request(allParams);
  }
  //学分明细
  log(param, cb) {
    var that = this;
    var allParams = {
      url: 'seller/shop-account',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //员工列表
  user(param, cb) {
    var expand = '';
    if(param.expand == 1){
      expand = '?expand=member';
    }
    var that = this;
    var allParams = {
      url: 'seller/user' + expand,
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //员工详情
  userDetail(param, cb) {
    var expand = '';
    var that = this;
    var allParams = {
      url: 'seller/user-info',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //添加员工
  userAdd(param, cb) {
    var expand = '';
    var that = this;
    var allParams = {
      url: 'seller/user-add',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //删除员工
  userDel(param, cb) {
    var expand = '';
    var that = this;
    var allParams = {
      url: 'seller/user-del',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
  //员工绑定小程序账户
  userBind(param, cb) {
    var expand = '';
    var that = this;
    var allParams = {
      url: 'seller/accept',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      },
    };
    this.request(allParams);
  }
}
export { Shop }